<html>
<head><meta charset="utf-8"><title>Investigating an LLVM internal error blocking a PR? · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html">Investigating an LLVM internal error blocking a PR?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="236121332"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/236121332" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#236121332">(Apr 26 2021 at 05:11)</a>:</h4>
<p>Does anyone have the bandwidth to investigate an LLVM issue that's been blocking a PR for some time now? <a href="https://github.com/rust-lang/rust/pull/81825">https://github.com/rust-lang/rust/pull/81825</a> is blocked by <a href="https://pipelines.actions.githubusercontent.com/DhU3eyB11Ei4viT99vzh0CpKzg7REqx1Nup2tB9LzmxBcoHdbh/_apis/pipelines/1/runs/8344/signedlogcontent/43?urlExpires=2021-04-26T05%3A10%3A28.3118596Z&amp;urlSigningMethod=HMACV1&amp;urlSignature=VAH%2F2e9amO%2F54uFup7UScJPXY5A5r7Mbq1imLk5wz6E%3D">this failure</a>:</p>
<div class="codehilite" data-code-language="Text only"><pre><span></span><code>2021-03-27T19:34:16.0666981Z rustc: /checkout/src/llvm-project/llvm/lib/CodeGen/RegAllocFast.cpp:883: void {anonymous}::RegAllocFast::defineVirtReg(llvm::MachineInstr&amp;, unsigned int, llvm::Register, bool): Assertion `PhysReg != 0 &amp;&amp; "Register not assigned"' failed.
2021-03-27T19:34:16.0668162Z error: ran out of registers during register allocation
</code></pre></div>
<p>Nobody involved in the issue has any idea how to address it.<br>
<a href="https://github.com/rust-lang/rust/issues/83854">https://github.com/rust-lang/rust/issues/83854</a> appears to have a somewhat simplified version of the same error.<br>
It'd really help to have someone with LLVM experience take a look at the issue.</p>



<a name="236250692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/236250692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#236250692">(Apr 26 2021 at 21:52)</a>:</h4>
<p>I may be able to look at this this weekend.</p>



<a name="236299944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/236299944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#236299944">(Apr 27 2021 at 08:24)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> Thank you, that would be deeply appreciated. <span aria-label="hearts" class="emoji emoji-2665" role="img" title="hearts">:hearts:</span>️</p>



<a name="237151502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237151502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237151502">(May 03 2021 at 12:12)</a>:</h4>
<p>I wasn't able to get to it last weekend <span aria-label="frown" class="emoji emoji-1f641" role="img" title="frown">:frown:</span></p>



<a name="237151916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237151916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237151916">(May 03 2021 at 12:16)</a>:</h4>
<p>This is related to stsack probes, though. <span class="user-mention" data-user-id="116083">@pnkfelix</span> wasn't the decision to force the inline probes to off until llvm 13?</p>



<a name="237151924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237151924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237151924">(May 03 2021 at 12:16)</a>:</h4>
<p>because of the codegen bug</p>



<a name="237152566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237152566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237152566">(May 03 2021 at 12:23)</a>:</h4>
<p>Well until the bug is fixed, at least. Someone said LLVM 13 in the meeting but I don’t know why we would commit to delaying that long if a backportable patch comes before then</p>



<a name="237176972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237176972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237176972">(May 03 2021 at 15:10)</a>:</h4>
<p>simplified to a </p>
<div class="codehilite"><pre><span></span><code>echo &quot;fn main() {}&quot; | ./build/i686-unknown-linux-gnu/stage1/bin/rustc - &quot;--target=i686-unknown-linux-gnu&quot; -Clto=thin -Ccodegen-units=1
</code></pre></div>
<p>for now...</p>



<a name="237187495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237187495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237187495">(May 03 2021 at 16:18)</a>:</h4>
<p>Huh. So the register allocation error happens even if you're not doing anything related to allocating a lot of registers (such as making a system call)?</p>



<a name="237187591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237187591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237187591">(May 03 2021 at 16:19)</a>:</h4>
<p>That's quite the misdirection. :)</p>



<a name="237187597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237187597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237187597">(May 03 2021 at 16:19)</a>:</h4>
<p>Thanks for investigating!</p>



<a name="237190109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237190109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237190109">(May 03 2021 at 16:38)</a>:</h4>
<p>This seems to me more like it could be a bug in regalloc, though I still haven't gotten to the point of looking at the machine code that triggers it.</p>



<a name="237190179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/237190179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#237190179">(May 03 2021 at 16:39)</a>:</h4>
<p>But if you run this with <code>-Cllvm-args=-verify-machineinstrs</code> the validation freaks out about invalid register constraints and whatnot which would suggest that it may be an issue in, say, fastisel too.</p>



<a name="238052245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/238052245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#238052245">(May 09 2021 at 18:26)</a>:</h4>
<p>Huh, this does not reproduce when cross-compiling. I tried a bunch of things, but I wasn't able to reduce case due to a number of complications: the issue involves LTO, regalloc, etc.</p>



<a name="238052252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/238052252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#238052252">(May 09 2021 at 18:27)</a>:</h4>
<p>I tried changing the strategy and using a debugger instead, but LLVM built with debug info no longer reproduces the issue <span aria-label="frown" class="emoji emoji-1f641" role="img" title="frown">:frown:</span></p>



<a name="238052273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/238052273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#238052273">(May 09 2021 at 18:27)</a>:</h4>
<p>If anybody else is interested in looking into this, feel free to do so.</p>



<a name="244150204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/Investigating%20an%20LLVM%20internal%20error%20blocking%20a%20PR%3F/near/244150204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Dominik Stolz <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F.html#244150204">(Jun 28 2021 at 14:11)</a>:</h4>
<p><span class="user-mention silent" data-user-id="123586">nagisa</span> <a href="#narrow/stream/187780-t-compiler.2Fwg-llvm/topic/Investigating.20an.20LLVM.20internal.20error.20blocking.20a.20PR.3F/near/237176972">said</a>:</p>
<blockquote>
<p>simplified to a </p>
<div class="codehilite"><pre><span></span><code>echo &quot;fn main() {}&quot; | ./build/i686-unknown-linux-gnu/stage1/bin/rustc - &quot;--target=i686-unknown-linux-gnu&quot; -Clto=thin -Ccodegen-units=1
</code></pre></div>
<p>for now...</p>
</blockquote>
<p>This does not longer trigger the assertion for me. However, changing <code>lto=thin</code> to <code>lto=fat</code> triggers it again.<br>
The number of CGUs does not seem to have an effect. However, setting<code>opt-level=1</code> prevents the issue.<br>
An updated reproduction would thus be:</p>
<div class="codehilite"><pre><span></span><code>echo &quot;fn main() {}&quot; | build/i686-unknown-linux-gnu/stage1/bin/rustc - &quot;--target=i686-unknown-linux-gnu&quot; -Clto=fat
</code></pre></div>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>